package com.jhhc.StormSurgeForecast.StormSurge.ServiceImpl;


import com.jhhc.StormSurgeForecast.StormSurge.Dao.BDMS_FBC_RESULT_SCHEMEMapper;
import com.jhhc.StormSurgeForecast.StormSurge.Pojo.FBC.BDMS_FBC_RESULT_SCHEME;
import com.jhhc.StormSurgeForecast.StormSurge.Service.BDMS_FBC_RESULT_SCHEMEService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BDMS_FBC_RESULT_SCHEMEServiceImpl implements BDMS_FBC_RESULT_SCHEMEService {

    @Autowired
    private BDMS_FBC_RESULT_SCHEMEMapper bdms_fbc_result_schemeMapper;
    @Value("${datasourceType}")
    String datasourceType;
    @Override
    public List<BDMS_FBC_RESULT_SCHEME> GetCalSchemeInfoByTyphoonIds(int projectId, int typhoonId,
                                    String starTime, String endTime,int modelID) {
        return bdms_fbc_result_schemeMapper.GetCalSchemeInfoByTyphoonIds(projectId, typhoonId, starTime, endTime,modelID);
    }

    @Override
    public List<BDMS_FBC_RESULT_SCHEME> GetCalSchemeInfoByTyphoonIds2(int projectId, int typhoonId, String starTime, String endTime, int modelId) {
        return bdms_fbc_result_schemeMapper.GetCalSchemeInfoByTyphoonIds2(projectId, typhoonId, starTime, endTime, modelId);
    }

    @Override
    public List<BDMS_FBC_RESULT_SCHEME> GetCalSchemeInfoByPid(int projectId, String startTime, String endTime,int modelID) {
       // return bdms_fbc_result_schemeMapper.GetCalSchemeInfoByPid(projectId,startTime,endTime,modelID);
        return  null;
    }

    @Override
    public List<BDMS_FBC_RESULT_SCHEME> selectByPid(int projectId, int scheme_id) {
        return bdms_fbc_result_schemeMapper.selectByPid(projectId, scheme_id);
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectLatestOneBySchemeId(int projectId, Integer typhoonId, String time,int modelId) {
        if (datasourceType.equals("mysql")){
            return bdms_fbc_result_schemeMapper.selectLatestOneBySchemeIdMysql(projectId, typhoonId, time,modelId);
        }else if (datasourceType.equals("sqlserver")){
            return bdms_fbc_result_schemeMapper.selectLatestOneBySchemeId(projectId, typhoonId, time,modelId);
        }

        return null;
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectLatestOneByFlag(int projectId, Integer typhoonId, String time,int modelId) {
        return bdms_fbc_result_schemeMapper.selectLatestOneByFlag(projectId, typhoonId, time,modelId);
    }

    @Override
    public List<BDMS_FBC_RESULT_SCHEME> GetCalSchemeInfoByPidTrue(int projectId, String startTime, String endTime, int modelId) {
        return bdms_fbc_result_schemeMapper.GetCalSchemeInfoByPidTrue(projectId, startTime, endTime, modelId);
    }

    @Override
    public List<BDMS_FBC_RESULT_SCHEME> GetCalSchemeInfoByPidFalse(int projectId, String startTime, String endTime, int modelId) {
        return bdms_fbc_result_schemeMapper.GetCalSchemeInfoByPidFalse(projectId, startTime, endTime, modelId);
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectSchemeByTime2(int projectId, String startTime, String endTime) {
        return bdms_fbc_result_schemeMapper.selectSchemeByTime2(projectId, startTime, endTime);
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectTimeByCalShemeId(int scheme_id) {
        return bdms_fbc_result_schemeMapper.selectTimeByCalShemeId(scheme_id);
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectTimeByCalShemeId1(int scheme_id, int modelId) {
        return bdms_fbc_result_schemeMapper.selectTimeByCalShemeId1(scheme_id, modelId);
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectSchemeByTime(int projectId, String startTime, String endTime) {




        if (datasourceType.equals("mysql")){
            return bdms_fbc_result_schemeMapper.selectSchemeByTimeMysql(projectId, startTime, endTime);
        }else if (datasourceType.equals("sqlserver")){
            return bdms_fbc_result_schemeMapper.selectSchemeByTime(projectId, startTime, endTime);
        }

        return null;

    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectSchemebyTime(int projectId, String startTime) {

        if (datasourceType.equals("mysql")){
            return bdms_fbc_result_schemeMapper.selectSchemebyTimeMysql(projectId, startTime);
        }else if (datasourceType.equals("sqlserver")){
            return bdms_fbc_result_schemeMapper.selectSchemebyTime(projectId, startTime);
        }

        return null;

    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectSchemeByTime3(int projectId, String startTime, String endTime, int modelId) {
        return bdms_fbc_result_schemeMapper.selectSchemeByTime3(projectId, startTime, endTime, modelId);
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectNewOneByModelId(int modelId ,String startTime,
                                                       String endTime) {
        return bdms_fbc_result_schemeMapper.selectNewOneByModelId(modelId,startTime,endTime);
    }

    @Override
    public BDMS_FBC_RESULT_SCHEME selectNewOne() {
        if (datasourceType.equals("mysql")){
            return bdms_fbc_result_schemeMapper.selectNewOne();
        }else if (datasourceType.equals("sqlserver")){
            return bdms_fbc_result_schemeMapper.selectNewOne();
        }
        return null;

    }


}
